# !/usr/bin/env python
# encoding: utf-8


"""
  @author: gaogao
  @file: plot_dialog.py
  @time: 2022/11/16 13:39
  @desc:
"""
import sys
from PyQt5 import QtWidgets
from PyQt5.QtCore import QSize, Qt, QRect, pyqtSignal
from PyQt5.QtGui import QIcon, QBrush, QColor, QPen, QFont, QPainter
from PyQt5.QtWidgets import QWidget, QDialog, QVBoxLayout,QHBoxLayout
from gui.custom_widget.my_matrix import Matrix


class PlotDialog(QDialog):
    def __init__(self):
        super().__init__()
        self.init_view()
        self.x_data = None
        self.y_data = None

    def init_view(self):
        self.setWindowTitle(f"曲线图")
        self.setFixedSize(QSize(950, 900))
        self.vl_plot = QVBoxLayout(self)
        self.vl_plot.setContentsMargins(0, 0, 0, 0)
        self.wd_plot = QWidget()
        self.hl_plot = QHBoxLayout(self.wd_plot)
        self.hl_plot.setSpacing(30)
        self.matrix = Matrix(self.wd_plot)
        self.hl_plot.addWidget(self.matrix)
        self.vl_plot.addWidget(self.wd_plot)



    def set_x_y_data(self, wafer_name,shot_pos,chip_name,parameter,x_label,y_label,x_data, y_data):
        self.x_data = x_data
        self.y_data = y_data
        self.matrix.setSupTitle(f"{wafer_name}-{shot_pos}-{chip_name}-{parameter}曲线")
        self.matrix.setX_label(x_label)
        self.matrix.setY_label(y_label)
        self.matrix.show_spines()
        self.matrix.show_grid()
        self.matrix.plot_curve(self.x_data, self.y_data, label=f"demo",is_invert_y=False, is_log=False)
